<template>
    <div>
        <el-row>
            <el-col :span="4"><el-button type="primary" plain @click="addpatient()">添加患者</el-button></el-col>
            <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
            <el-col :span="4"><el-input v-model="input" placeholder="请输入内容" prefix-icon="el-icon-search"></el-input></el-col>
            <el-col :span="4"><el-button type="primary" plain>查询</el-button></el-col>
            <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
            <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
        </el-row> 
        <el-table :data="tableData" border style="width: 97%">
            <el-table-column prop="name" label="姓名" width="180" align="center"></el-table-column>
            <el-table-column prop="idcard" label="身份证号" width="180" align="center"></el-table-column>
            <el-table-column prop="gender" label="性别" width="60px" align="center"></el-table-column>
            <el-table-column prop="address" label="住址" ></el-table-column>
            <el-table-column label="住院日期" align="center" width="120px">
                <template slot-scope="scope">
                    <i class="el-icon-time"></i>
                    <span style="margin-left: 10px">{{ scope.row.date }}</span>
                </template>
            </el-table-column>
            <el-table-column prop="source" label="感染来源" ></el-table-column>
            <el-table-column label="操作" align="center" width="280px">
                <template slot-scope="scope">
                <el-button size="mini" @click="shouwByid()">编辑</el-button>
                <el-button size="mini" type="primary" plain @click="showrecord">检测记录</el-button>
                <el-button size="mini" type="primary" plain @click="showCureDialog()">治愈</el-button>
                </template>
            </el-table-column>
        </el-table>

         <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400">
        </el-pagination>

       <!-- <el-button type="text" @click="dialogFormVisible = true"></el-button> -->

        <el-dialog title="治愈" :visible.sync="dialogFormVisible">
        <el-form :model="form">
            <el-form-item label="" :label-width="formLabelWidth">
                治愈时间
                 <el-date-picker v-model="form.date" type="date" placeholder="选择日期"></el-date-picker>
            
            </el-form-item>
            <el-form-item label="" :label-width="formLabelWidth">
                备注
                <el-input type="textarea" v-model="form.desc" rows="4" placeholder="请输入"></el-input>
            
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
        </div>
        </el-dialog>


    </div>
</template>
<script>
import request from '@/utils/request'
export default {
  data() {
    return {
        input: '',
        tableData: null,
        currentPage1: 5,
        currentPage2: 5,
        currentPage3: 5,
        currentPage4: 4,
        dialogTableVisible: false,
        dialogFormVisible: false,
        form: {          
          date: '',
          desc: ''
        },
        formLabelWidth: '120px'
    }
  },
  created(){
      this.fetchData()
  },
  methods: {
      fetchData() {
          request({
              url:'../patient_list.json',
              method:'get'
          }).then((response)=>{
              this.tableData=response.data
          })
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
        },
        shouwByid(){
            this.$router.push({
				path:'/patient/modify'
			})
        },
        showrecord(){
            this.$router.push({
				path:'/testrecord/testrecordlist'
			})
        },
        showCureDialog(){
            this.dialogFormVisible=true
        },
        addpatient(){
            this.$router.push({
				path:'/patient/addpatient'
			})
        }
    }
}
</script>